package edu.njust.httpmanager.utils;

import edu.njust.httpmanager.constance.ResponseCode;
import edu.njust.httpmanager.exception.CustomException;
import org.apache.commons.validator.routines.EmailValidator;

/**
 * 校验参数是否合法
 */
public class ValidatorUtil {


    public static boolean isValidEmail(String email) {
        return EmailValidator.getInstance().isValid(email);
    }

    public static boolean isNotValidEmail(String email) {
        return !isValidEmail(email);
    }

    public static void requireNonnull(Object object, String message) {

        if (object == null) {
            throw new CustomException(ResponseCode.PARAMS_ERROR, message);
        }
    }


}
